import 'package:flutter/material.dart';
import 'package:flutter_base/provider_demo/models/user_model2.dart';
import 'package:provider/provider.dart';

class TestPgae extends StatefulWidget {
  const TestPgae({super.key});

  @override
  State<TestPgae> createState() => _TestPgaeState();
}

class _TestPgaeState extends State<TestPgae> {
  @override
  Widget build(BuildContext context) {
    return Scaffold(
      appBar: AppBar(title: const Text('测试页面')),
      body: Center(
        child: Column(
          mainAxisAlignment: MainAxisAlignment.center,
          children: <Widget>[
            Consumer<UserModel2>(
              builder: (context, value, child) => Text(value.name),
            ),
            Consumer<UserModel2>(
              builder: (context, value, child) => Padding(
                padding: const EdgeInsets.all(20),
                child: ElevatedButton(
                  onPressed: () {
                    value.changeName('good bye');
                  },
                  child: const Text('修改'),
                ),
              ),
            )
          ],
        ),
      ),
    );
  }
}
